package com.fzb.zrlog.simple.dao.impl;

import com.fzb.common.dao.impl.DAO;
import com.fzb.zrlog.simple.dao.api.ILogNavDAO;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class LogNav extends DAO implements ILogNavDAO {

    public LogNav() {
        tableName = "lognav";
        pk = "logNavId";
    }

    @Override
    public List<Map<String, Object>> queryAll(String baseUrl) {
        List<Map<String, Object>> navs = queryAll();
        for (Map logNav : navs) {
            if (logNav.get("url").toString().startsWith("/")) {
                logNav.put("url", baseUrl + logNav.get("url"));
            }
        }
        return navs;

    }

    @Override
    public List<Map<String, Object>> queryAll() {
        List<Map<String, Object>> navs = new ArrayList<>();
        try {
            navs = queryList(ALL);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return navs;
    }

    @Override
    public Map<String, Object> queryAll(Integer page, Integer pageSize) {
        return null;
    }

}
